package com.neusiri.customer;

import com.neusiri.util.SmsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * smsCustomer
 * 短信发送消费者[持久化 非独占 不是自动删除的队列]
 * @author 丛有志
 * @date 2020/11/12 20:18
 * <p>
 * 版本        修改时间        作者        修改内容
 * V1.0        2020/11/12     丛有志        初始版本
 */
@Slf4j
@Component
@RabbitListener(queuesToDeclare = @Queue("hello"))
public class SmsCustomer {

    @Resource
    private SmsUtil smsUtil;

    @RabbitHandler
    public void sendSms(Map<String, String> map) {
        String mobile = map.get("mobile");
        String picCode = map.get("picCode");
        boolean flag = smsUtil.sendPicCode(mobile, picCode);
        log.info("验证码发送状态："+flag);
    }
}
